<?php

    session_start();
    
    //Inclui o arquivo de configuracao do Framework.
   include_once 'framework/Config.php';

    /**
    * __autoload, inclui as classes dinamicamente
    * @param $class
    */
    spl_autoload_register(function ($class) {
        $classPath = Config::$CLASS_PATH;
        foreach ($classPath as $Path) {
            if (file_exists("{$Path}/{$class}.php")) {
                require_once "{$Path}/{$class}.php";
                return true;
            }
        }
        return false;
    });

    
//	Secutiry::registerUser(array('usuario' => 'thyago', 'profille' => array('ADMINISTRADOR')), 'thyago');
    
//     echo 'var_dump Session na index';
//     var_dump($_SESSION);

//    Secutiry::logout();

    /*
     * Utilizado para testar permissões utilizadno PHPDoc
    echo '###########';
    $reflection = new ReflectionClass('Mustache');
    echo '<pre>';
    print_r($reflection->getDocComment());
    $class_metadata = parse_doc($reflection->getDocComment());
    print_r($class_metadata);
    echo '###########***********************##################';

    $methods = $reflection->getMethods(ReflectionMethod::IS_PUBLIC + ReflectionMethod::IS_PROTECTED);
    foreach ($methods as $method) {
    	$doc = $method->getDocComment();
    	$class_metadata = parse_doc($doc);
    	print_r($class_metadata);
    	echo '<pre>';
    	print_r($doc);
    }
    die();
    */
    // Configuracao da URL
    Uri::setURI();
    
    function parse_doc($php_doc_comment){
    	$p = new PHPDocParser();
    	return $p->parse($php_doc_comment);
    	$p = new Parser($php_doc_comment);
    	return $p;
    	$php_doc_comment = preg_replace("/(^[\\s]*\\/\\*\\*)
                                     |(^[\\s]\\*\\/)
                                     |(^[\\s]*\\*?\\s)
                                     |(^[\\s]*)
                                     |(^[\\t]*)/ixm", "", $php_doc_comment);
    
    	$php_doc_comment = str_replace("\r", "", $php_doc_comment);
    	$php_doc_comment = preg_replace("/([\\t])+/", "\t", $php_doc_comment);
    	return explode("\n", $php_doc_comment);
    
    
    	$php_doc_comment =  trim(preg_replace('/\r?\n *\* */', ' ',
    	$php_doc_comment));
    	return $php_doc_comment;
    	preg_match_all('/@([a-z]+)\s+(.*?)\s*(?=$|@[a-z]+\s)/s',
    	$php_doc_comment, $matches);
    	return array_combine($matches[1], $matches[2]);
    }

?>	